import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class LoginWindow extends JDialog {

	public LoginWindow() {
		super();
		Container contents = getContentPane();
		contents.setLayout(new BorderLayout());
		setTitle("xTARDIS Login");
		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);

		this.setModal(true);

		JPanel inputPanel = new JPanel(new GridLayout(2,2));

		//The input fields
		inputPanel.add(new JLabel("Username:"));
		inputPanel.add(new JTextField());
		inputPanel.add(new JLabel("Password:"));
		inputPanel.add(new JPasswordField());

		contents.add(inputPanel, BorderLayout.CENTER);


		JPanel buttonPanel = new JPanel(new FlowLayout());

		//the buttons
		JButton loginButton = new JButton("Login");
		loginButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				setVisible(false);
				dispose();
			}
		});
		buttonPanel.add(loginButton);

		// space
		//buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

		// cancel button
		JButton cancelButton = new JButton("Cancel");
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				setVisible(false);
				dispose();
			}
		});
		buttonPanel.add(cancelButton);

		contents.add(buttonPanel, BorderLayout.SOUTH);


		getRootPane().setDefaultButton(loginButton);
		pack();
	}
}
